﻿using Sai.Core;
using Sai.Core.Rules;
using Sai.Test.TestDataBuilders;
using Sai.Test.XUnit;
using Xunit;

namespace Sai.Test.Rules
{
    public class CheckTypeFieldsFacts
    {
        [Fact, TouchingFileSystemTest]
        public void Identical_Class_In_Both_Versions_Shows_Zero_Changes()
        {
            const string className = "Class1";
            const string field = "public int MyField;";

            var oldClassBuilder = CompilableClassBuilder.PublicClass()
                .Named(className)
                .WithField(field);

            string oldCode = BoilerPlateCodeBuilder.BuildFor(oldClassBuilder);

            var newClassBuilder = CompilableClassBuilder.PublicClass()
                .Named(className)
                .WithField(field);

            string newCode = BoilerPlateCodeBuilder.BuildFor(newClassBuilder);

            IProductReleaseProject project = Mock.MinimalProject();

            TypeDifference diff = TypeDifferenceBuilder.Differences()
                .CodeWas(oldCode)
                .CodeIsNow(newCode)
                .CheckedUsing(new CheckTypeFields())
                .Build();

            Assert.False(diff.HasChanged);

            Assert.Null(diff.FieldsAdded);
            Assert.Null(diff.FieldsChanged);
            Assert.Null(diff.FieldsObsolete);
            Assert.Null(diff.FieldsRemoved);
        }
    }
}
